<?php
/**
 *      
 * 
 *  @author          Edmandie Samonte        (edmandie.samonte@gmail.com)
 *  @copyright       2011 
 * 
 */
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Dashboard</title>
        <script type="text/javascript" src="<?php echo load_js('jquery.min.js');?>" ></script>
        <script type="text/javascript" src="<?php echo load_js('jquery.validate.min.js');?>" ></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $('#filter').keyup(function(){
                    rx = new RegExp($('#filter').val().toUpperCase(),'g');
                    $data = $('.employee-data');
                    $data.each(function(){
                        if(!rx.test($(this).html().toUpperCase())){
                            $(this).parent().hide('medium');
                        }else{
                            $(this).parent().show('medium');
                        }
                        
                    });
                });
            });
        </script>
        <style type="text/css" media="screen">
            @import url(<?php echo load_css('common.css');?>);
            @import url(<?php echo load_css('header.css');?>);
            @import url(<?php echo load_css('dashboard.css');?>);
            @import url(<?php echo load_css('logged_in.css');?>);
            @import url(<?php echo load_css('add.css');?>);
        </style>
    </head>
    <body>
        <div class="main-container">
            <?php require_once 'header.php';?>
            <span class="page-title">Attendance</span>
            <div class="post-head">
                <table >
                    <tr>
                        <td>
                            <img src="<?php echo load_image('profile_pic/'. $user->ePictureURL); ?>" title="" alt="" height="125"/>
                        </td>
                        <td style="width:20px"></td>
                        <td>
                            <span class="user_name"><?php echo $user->eFirstName . " " .$user->eMiddleName . " " . $user->eLastName; ?></span><br/>
                            <span class="user_position"><?php echo $position;?></span><br/>
                            <span class="user_id">ID# <?php echo str_pad($user->eID,4,"0",STR_PAD_LEFT);?></span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="clearfix">
                <div id="right">
                    <div class="navigation">
                    <div class="pane-title">Navigation</div>
                        <div class="controls">
                            <a href="<?php echo site_url('dashboard');?>">Dashboard</a><br/>
                            <a href="<?php echo site_url('employee/add'); ?>">Add Employee</a><br/>
                            <a href="<?php echo site_url('dashboard/logout'); ?>">Logout</a>
                        </div>
                    </div>
                    <div style="height:40px;"></div>
                    <div class="navigation">
                    <div class="pane-title"><?php echo $user->eFirstName;?>'s Navigation</div>
                        <div class="controls">
                            <a href="<?php echo site_url('employee/profile/'.$user->eID) ?>" >Profile</a><br/>
                            <a href="<?php echo current_url(); ?>" class="selected">Attendance Record</a><br/>
                            <a href="<?php echo site_url('employee/edit/'.$user->eID);?>">Edit Profile</a><br/>
                        </div>
                    </div>
                </div>
                <div id="left">
                    <div class="pane-title">Attendance</div>
                    <input type="button" id="t_in"value="Time In" class="gb" />
                    <div id="timein" style="display:none">
                        <form id="main-form" action="<?php echo current_url()?>" method="post">
                            <table class="form-table">
                                <tr>
                                    <td class="label">
                                        <span>Remarks</span>
                                    </td>
                                    <td>
                                        <input type="text" name="remarks" class="required input" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        <span>Check to verify</span>
                                    </td>
                                    <td>
                                        <input type="checkbox" name="verify" class="required input" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                    </td>
                                    <td>
                                        <input type="submit"  value="Submit" class="gb" />
                                        <input type="hidden" name="eID" value="<?php echo $user->eID;?>" />
                                        <input type="hidden" name="vID" value="<?php echo $vID;?>" />
                                        <input type="hidden" name="time_in" value="1" />
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <script type="text/javascript">
                        $('#t_in').click(function(){
                            $('#timein').show('medium');
                        });
                        $('#main-form').validate();
                    </script>
                    <div class="separator"></div>
                    <div style="width:500px;margin:0 auto">
                        <table class="form-table">
                            <?php foreach($att as $a): ?>
                                <tr>
                                    <td class="label">
                                        <span><?php echo date("l",strtotime($a->aDate));?></span><br/>
                                        <span><?php echo date("M d, Y",strtotime($a->aDate));?></span><br/>
                                    </td>
                                    <td>
                                        <?php $time= getdate($a->aTimeIn) ;?>
                                        <span class="remarks">Time in: <?php echo  $time['hours']+8 . ":" . $time['minutes']?></span><br/>
                                        <?php if($a->aTimeOut != ''): ?>
                                            <?php $time= getdate($a->aTimeOut) ;?>
                                            <span class="remarks">Time Out: <?php echo  $time['hours']+8 . ":" . $time['minutes']?></span><br/>
                                            <span class="remarks">Total Hours: <?php echo  $a->aTotalHours?></span><br/>
                                        <?php else: ?>
                                            <span class="remarks">Time Out: <input type="button" id="timeout<?php echo $a->aID; ?>" value="Time Out" class="gb" /></span><br/>
                                            <form id="t_form<?php echo $a->aID; ?>"action="<?php echo current_url();?>" method="post" />
                                                <input type="hidden" name="time_in" value="0" />
                                                <input type="hidden" name="aID" value="<?php echo $a->aID; ?>" />
                                            </form>
                                            <script type="text/javascript" >
                                                $('#timeout<?php echo $a->aID; ?>').click(function(){
                                                    $('#t_form<?php echo $a->aID; ?>').submit();
                                                });
                                            </script>
                                        <?php endif; ?>
                                        <span class="remarks">Verified by: <?php echo  $vUser->eFirstName . " " . $vUser->eLastName ?></span><br/>
                                    </td>
                                </tr>
                            <?php endforeach;?>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
